home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / bfile / bfile.h < prev    next >
Text File  |  1991-09-06  |  3KB  |  84 lines

  1. /*
  2.  
  3.       bfile.h
  4.       Btrieve class for Borland C++
  5.       09/06/91
  6.  
  7.       Douglas J. Reilly
  8.       Access Microsystems Inc.
  9.       404 Midstreams Road
  10.       Brick, New Jersey  08724
  11.       (908) 892-2683
  12.       CompuServe 74040,607
  13.  
  14.       Comments?  Questions?  Suggestions?
  15.       Have a paying C/C++ programming job you need done?
  16.       Give me a call.
  17.  
  18.       Released into the public domain.  Do with it as you see fit, but
  19.       if you do anything really neat with it, let me know...
  20.  
  21. */
  22.  
  23. #ifndef BFILE_H
  24. #define BFILE_H
  25. #include "btrieve.h"
  26. extern "C" {
  27. int BTRV(int ,char *,char *,int *,char *,int );
  28. }
  29.  
  30. class bfile {
  31.    char pos_blk[128];        // position block
  32.    char fname[64];           // physical file name
  33.    char logical_name[10];    // logical file name (not used yet)
  34.    int  mode;                // open mode
  35.    int  rec_len;             // record len
  36.    int  key_num;             // current key number
  37.    int  status;              // error status
  38.    int  opened;              // opened flag, not really essential because data
  39.                              //   seemed like it was as natural a flag
  40.                              //   as possible, since we don't want to write
  41.                              //   data to null.
  42.    char *data;               // The data, of course...
  43.    char owner[60];           // owner of the file, used for secured files.
  44. public:
  45.   // file name, lenght, owner, and open mode
  46.   // Note that constructor opens file.
  47.    bfile(char *name,int len,char *towner=0,int newmode=0);
  48.    ~bfile();
  49.   // Close file, free up data pointer above.
  50.    int  close();
  51.   // Open, really SB reopen I guess since only useful after close...
  52.    int  open(int newmode=-1);
  53.   // Gets a record.  Uses key 0 unless you set key number (below).
  54.    int  get_rec(char *keystr,int op=B_GET_EQ);
  55.   // Self explanatory...
  56.    void set_key_num(int key=0)
  57.         {
  58.            key_num=key;
  59.         }
  60.   // take newdata and copy it into the data element.
  61.    int  set_data(char *newdata)
  62.         {
  63.            if ( data!=NULL )
  64.            {
  65.               memcpy(data,newdata,rec_len);
  66.               return(1);
  67.            }
  68.            return(0);
  69.         }
  70.   // return pointer to data.
  71.    char *get_data()
  72.         {
  73.            return data;
  74.         }
  75.   // Insert or update record.  could make seperate functions to force one
  76.   //   or the other.  I prefer this.
  77.    int  put_rec(char *keystr,int =0);
  78.   // self explanatory...
  79.    int  del_rec(char *keystr);
  80.   // allow user to get status after operation.
  81.    int  get_status(){ return status; }
  82. };
  83. #endif
  84.